<?
    include './address.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <?
        // echo "<pre>";
        // print_r($address);
        // echo "</pre>";
    ?>
    <select name="" id="province">
        <option value="">请选择</option>
        <?
            foreach( $address as $provinceId => $province ){
                if ( !empty( $province['province_name'] ) ){
                    ?>
                    <option value="<?echo $provinceId?>"><?echo$province['province_name']?></option>
                    <?
                }
            }
        ?>
    </select>
    <select name="" id="city">
        
    </select>
    <select name="" id="areaId">

    </select>
    <script>
        let provinceEle = document.querySelector("#province");
        let cityEle = document.querySelector("#city");
        let areaEle = document.querySelector("#areaId");
        provinceEle.onchange = function (){
            cityEle.innerHTML = `
            <?
                foreach( $address[$this.value] as $provinceId => $province ){
                    if ( !empty( $province['province_name'] ) ){
                        ?>
                        <option value="<?echo $provinceId?>"><?echo$province['province_name']?></option>
                        <?
                    }
                }
            ?>            
            `;
        }
    </script>
</body>
</html>